package com.dto;

import lombok.Data;

@Data
public class JsonResponseInt<T> {
    private Integer code;

    private String msg;

    private T data;


    public JsonResponseInt(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public JsonResponseInt(T data) {
        this.data = data;
        this.msg = "成功";
        this.code = 0;
    }

    public static JsonResponseInt<String> success() {
        return new JsonResponseInt<>(null);
    }

    public static JsonResponseInt<String> success(String data) {
        return new JsonResponseInt<>(data);
    }

    public static JsonResponseInt<String> fail() {
        return new JsonResponseInt<>(1, "失败");
    }

    public static JsonResponseInt<String> fail(Integer code, String msg) {
        return new JsonResponseInt<>(code, msg);
    }
}

